<template>
  <div class="app-container">
    <el-form
      class="dialog-form"
      :rules="rules"
      ref="dataForm"
      :model="temp"
      label-position="left"
      label-width="120px"
    >
      <el-form-item label="版本号" prop="versionNo">
        <el-input v-model="temp.versionNo" placeholder="版本号" style="width:300px;"></el-input>
      </el-form-item>
     
      <el-form-item label="版本描述" prop="versionDesc">
        <el-input v-model="temp.versionDesc" placeholder="在这里写版本描述" type="textarea" :rows="3" style="width:300px;"></el-input>
      </el-form-item>

       <el-form-item label="app类型" prop="systemType">
          <el-select v-model="temp.systemType" placeholder="请选择app类型">
            <el-option v-for="(list,key) in appTypes" :key="key" :value="list" :label="list"></el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="app路径" prop="appUrl">
        <el-input v-model="temp.appUrl" placeholder="在这里写app路径" style="width:300px;"></el-input>
      </el-form-item>

      <el-form-item label="是否使用" prop="useStatus">
        <el-radio v-model="temp.useStatus" label="1">是</el-radio>
        <el-radio v-model="temp.useStatus" label="0">否</el-radio>
      </el-form-item>

    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button size="mini" @click="dialogFormVisible = false">取消</el-button>
      <el-button type="primary" size="mini" :loading="submiting" @click="submitFormAction">确定</el-button>
    </div>
  </div>
</template>

<script>
import "quill/dist/quill.core.css";
import "quill/dist/quill.snow.css";
import "quill/dist/quill.bubble.css";
import { quillEditor, Quill } from "vue-quill-editor";

export default {
  data() {
    return {
      container: false,
      total: 0,
      params: {
        pageNo: 1,
        pageSize: 20
      },
      appTypes:{
          '0':'Android版',
          '1':'IOS版',
          '2':'PC版'
      },
      cmsList: [],
      list: [],
      permissionsList:[],
      temp: {
        systemType: "",
        versionDesc: ""
      },
      editorOption: {
        placeholder: "在这里输入内容",
        modules: {}
      },
      rules: {
        versionNo: [
          {
            required: true,
            message: "版本号",
            trigger: "change",
            max: 50
          }
        ],
        versionDesc: [
          { required: true, message: "版本描述", trigger: "change" }
        ],
        appUrl: [
          { required: true, message: "app路径不能为空", trigger: "change" }
        ],
        useStatus: [{ required: true, message: "是否使用不能为空", trigger: "change" }],
        systemType: [{ required: true, message: "app类型不能为空", trigger: "change" }]
      }
    };
  },
  components: {
    quillEditor
  },
  created() {
    this.loadData();
  },
 
  methods: {
    submitFormAction() {
      this.$refs["dataForm"].validate(valid => {
        if (valid) {
          this.submiting = true;
          const postData = Object.assign({}, this.temp);
          let url = "/admin/app_version/add";
        //   if (this.isEditing) {
        //     url = "/admin/cms_category/modify";
        //   }
          this.$post(url, postData)
            .then(data => {
                this.$$notify("操作成功");
                this.temp ={};
                this.loadData();
                this.dialogFormVisible = false;
            })
          .finally(err => {
            this.submiting = false
          })
        }
      });
    }
  }
};
</script>
<style>
.el-table td,
.el-table th {
  padding: 1px 0;
}
.el-table {
  font-size: 12px;
}
.opencolor {
  color: red;
}
.openSearch {
  /* width: 100px; */
  margin-bottom: 10px;
  padding-bottom: 5px;
  /* border-bottom: 1px solid #ccc; */
}
</style>